def calculate(num1, operator, num2):
    if operator == '+':
        return num1 + num2
    elif operator == '-':
        return num1 - num2
    elif operator == '*':
        return num1 * num2
    elif operator == '/':
        if num2 == 0:
            print("错误：除数不能为0")
            return None
        return num1 / num2
    else:
        print("错误：不支持的操作符")
        return None


def main():
    while True:
        try:
            num1 = float(input("请输入一个数字: "))
            operator = input("请输入操作符（+ - * /）: ")
            num2 = float(input("请再次输入一个数字: "))

            result = calculate(num1, operator, num2)
            if result is not None:
                print("计算结果为:", result)

                # 提示用户是否继续
            continue_input = input("是否继续计算？（y/n）: ").lower()
            if continue_input != 'y':
                break

        except ValueError:
            print("错误：请输入有效的数字。")


if __name__ == "__main__":
    main()